package Dbc;

import java.sql.*;

public class DbConnection {
    private Connection conn = null;

    public DbConnection() throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");//com.mysql.jdbc.Driver
        String url = "jdbc:mysql://localhost:3306/hospitalmanagement?characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true";
        String username = "root";
        String password = "huangjiasen";
        conn = DriverManager.getConnection(url, username, password);

    }

    public Connection getConnection() {
        return this.conn;
    }

    public void closeConnection() throws SQLException {
        if (this.conn != null) {
            this.conn.close();
        }
    }
}
